#include <iostream>
#include <string.h>
using namespace std;

//参数模板 本质: 类型 参数化
//让你对字符数组 int数组进行排序

template <typename T>
int mySort(T *array, int size){
        int i , j;
        T tmp;

        if(array == NULL){
                return -1;
        }

        for (i= 0; i < size; i++){
               for (j = i+1; j < size; j++){
                        if(array[i] < array[j]){
                                tmp = array[i];
                                array[i] = array[j];
                                array[j] = tmp;
                        }               
               }
        }
        
        return 0;
}

template <typename T>
void myPrint(T *array, int size){
        for (int i = 0; i < size; i++){
                cout<<array[i]<<" ";       
        }
        cout<<endl;
}

int main03(int argc, char const *argv[]){
        int myarray[] = {11, 33, 44, 22, 2, 3, 6, 9};
        int size = sizeof(myarray)/sizeof(*myarray);

        mySort<int>(myarray, size);

        printf("排序之后\n");
        myPrint<int>(myarray, size);

        char buf[] = "affwe55ertsdadas";
        int len  = strlen(buf);
        mySort<char>(buf, len);
        myPrint<char>(buf,len);

        return 0;
}
